package net.adst.util;

import net.adst.beans.OurTecRow;
import net.adst.resources.VariableNames;

import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * User: Администратор
 * Date: 08.01.13
 * Time: 22:24
 * To change this template use File | Settings | File Templates.
 */
public class OurTecCellRender extends DefaultTableCellRenderer {
    public OurTecCellRender() {
        super();
        setOpaque(true);
    }

    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
        OurTecRow tec = ((ArrayList<OurTecRow>) DataManager.getObject(VariableNames.TEC_OUR_USING_ROWS)).get(row);
        setHorizontalAlignment(SwingConstants.CENTER);
        if (!isSelected) {
            if (tec.getPaidFor()) {
                setBackground(Color.YELLOW);
                setForeground(Color.BLACK);
            } else {
                setBackground(Color.WHITE);
                setForeground(Color.BLACK);
            }
        }    else{
            setBackground(Color.BLUE);
            setForeground(Color.WHITE);
        }
        setText(value != null ? value.toString() : "");
        return this;
    }

}
